package panyy.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import panyy.domain.User;
import panyy.mapper.UserMapper;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User findById(int id){
        return userMapper.findById(id);
    }

    @Transactional
    public int insert(User user){
        user.setAge(user.getAge()+10);
        userMapper.insert(user);
        user.setAge(user.getAge()-20);
        return userMapper.insert(user);
    }
}
